import Mock from 'mockjs2'
import { builder } from '../util'

const info = options => {
  console.log('options', options)
  const userInfo = {
    id: '4291d7da9005377ec9aec4a71ea837f',
    name: 'Admin',
    username: 'admin',
    password: '',
    avatar: '/avatar2.jpg',
    status: 1,
    telephone: '',
    lastLoginIp: '27.154.74.117',
    lastLoginTime: 1534837621348,
    creatorId: 'admin',
    createTime: 1497160610259,
    merchantCode: 'TLif2btpzg079h15bk',
    deleted: 0,
    roleId: 'admin',
    role: {}
  }
  // role
  const roleObj = {
    id: 'admin',
    name: '管理员',
    describe: '拥有所有权限',
    status: 1,
    creatorId: 'system',
    createTime: 1497160610259,
    deleted: 0,
    permissions: [
      {
        roleId: 'admin',
        permissionId: 'dashboard',
        permissionName: '仪表盘',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'exception',
        permissionName: '异常页面权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'result',
        permissionName: '结果权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'profile',
        permissionName: '详细页权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'table',
        permissionName: '表格权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"import","defaultCheck":false,"describe":"导入"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'import',
            describe: '导入',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'form',
        permissionName: '表单权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'order',
        permissionName: '订单管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'permission',
        permissionName: '权限管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'role',
        permissionName: '角色管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'table',
        permissionName: '桌子管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'user',
        permissionName: '用户管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"import","defaultCheck":false,"describe":"导入"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"},{"action":"export","defaultCheck":false,"describe":"导出"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'import',
            describe: '导入',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          },
          {
            action: 'export',
            describe: '导出',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      }
    ]
  }

  roleObj.permissions.push({
    roleId: 'admin',
    permissionId: 'support',
    permissionName: '超级模块',
    actions:
      '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"import","defaultCheck":false,"describe":"导入"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"},{"action":"export","defaultCheck":false,"describe":"导出"}]',
    actionEntitySet: [
      {
        action: 'add',
        describe: '新增',
        defaultCheck: false
      },
      {
        action: 'import',
        describe: '导入',
        defaultCheck: false
      },
      {
        action: 'get',
        describe: '详情',
        defaultCheck: false
      },
      {
        action: 'update',
        describe: '修改',
        defaultCheck: false
      },
      {
        action: 'delete',
        describe: '删除',
        defaultCheck: false
      },
      {
        action: 'export',
        describe: '导出',
        defaultCheck: false
      }
    ],
    actionList: null,
    dataAccess: null
  })

  userInfo.role = roleObj
  return builder(userInfo)
}

/**
 * 使用 用户登录的 token 获取用户有权限的菜单
 * 返回结构必须按照这个结构体形式处理，或根据
 * /src/router/generator-routers.js  文件的菜单结构处理函数对应即可
 * @param {*} options
 * @returns
 */
// const userNav = options => {
//   const nav = [
//     // dashboard
//     {
//       name: 'dashboard',
//       parentId: 0,
//       id: 1,
//       meta: {
//         icon: 'dashboard',
//         title: '仪表盘',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/dashboard/workplace'
//     },
//     {
//       name: 'workplace',
//       parentId: 1,
//       id: 2,
//       meta: {
//         title: '日曆任務',
//         show: true
//       },
//       component: 'Workplace'
//     },
//     {
//       name: 'general',
//       parentId: 0,
//       id: 3,
//       meta: {
//         icon: 'table',
//         title: '常規管理',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/general/warehouse'
//     },
//     {
//       name: 'warehouse',
//       parentId: 3,
//       id: 4,
//       meta: {
//         title: '倉庫設定',
//         show: true
//       },
//       component: 'warehouse'
//     },
//     {
//       name: 'employee',
//       parentId: 3,
//       id: 6,
//       meta: {
//         title: '公司、倉庫及司機員工設定',
//         show: true
//       },
//       component: 'employee'
//     },
//     {
//       name: 'branch',
//       parentId: 3,
//       id: 7,
//       meta: {
//         title: '分店設定',
//         show: true
//       },
//       component: 'branch'
//     },
//     // {
//     //   name: 'supplier',
//     //   parentId: 3,
//     //   id: 8,
//     //   meta: {
//     //     title: '供應商設定',
//     //     show: true
//     //   },
//     //   component: 'supplier'
//     // },
//     {
//       name: 'suppliers',
//       parentId: 0,
//       id: 9,
//       meta: {
//         icon: 'table',
//         title: '供應商管理',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/suppliers/quotation'
//     },
//     {
//       name: 'storehouse',
//       parentId: 0,
//       id: 10,
//       meta: {
//         icon: 'table',
//         title: '倉存管理',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/storehouse/rurchaseRecord'
//     },
//     {
//       name: 'purchases',
//       parentId: 0,
//       id: 11,
//       meta: {
//         icon: 'table',
//         title: '分店採購管理',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/purchases/purchaseRecord'
//     },
//     {
//       name: 'dispatch',
//       parentId: 0,
//       id: 12,
//       meta: {
//         icon: 'table',
//         title: '派貨記錄',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/dispatch/deliverySetting'
//     },
//     {
//       name: 'purchaseListSetting',
//       parentId: 0,
//       id: 13,
//       meta: {
//         icon: 'table',
//         title: '採購清單設定',
//         show: true
//       },
//       component: 'PurchaseListSetting'
//     },
//     {
//       name: 'cost',
//       parentId: 0,
//       id: 14,
//       meta: {
//         icon: 'table',
//         title: '成本數據管理',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/dashboard/workplace'
//     },
//     {
//       name: 'statement',
//       parentId: 0,
//       id: 15,
//       meta: {
//         icon: 'table',
//         title: '報表',
//         show: true
//       },
//       component: 'RouteView',
//       redirect: '/dashboard/workplace'
//     },
//     {
//       name: 'notice',
//       parentId: 0,
//       id: 16,
//       meta: {
//         icon: 'table',
//         title: '消息管理',
//         show: true
//       },
//       component: 'Notice'
//     },
//     // {
//     //   name: 'system',
//     //   parentId: 0,
//     //   id: 17,
//     //   meta: {
//     //     icon: 'table',
//     //     title: '系统管理',
//     //     show: true
//     //   },
//     //   component: 'RouteView',
//     //   redirect: '/dashboard/workplace'
//     // },
//     {
//       name: 'quotation',
//       parentId: 9,
//       id: 18,
//       meta: {
//         title: '供應商報價單',
//         show: true
//       },
//       component: 'QuotationManagement'
//     },
//     {
//       name: 'purchaseOrder',
//       parentId: 9,
//       id: 19,
//       meta: {
//         title: '採購單給供應商',
//         show: true
//       },
//       component: 'PurchaseOrder'
//     },
//     {
//       name: 'invoice',
//       parentId: 9,
//       id: 20,
//       meta: {
//         title: '供應商發票',
//         show: true
//       },
//       component: 'SupplierInvoice'
//     },
//     {
//       name: 'supplierManagement',
//       parentId: 9,
//       id: 21,
//       meta: {
//         title: '供應商管理',
//         show: true
//       },
//       component: 'SupplierManagement'
//     },
//     {
//       name: 'RurchaseRecord',
//       parentId: 10,
//       id: 22,
//       meta: {
//         title: '進貨記錄',
//         show: true
//       },
//       component: 'RurchaseRecord'
//     },
//     {
//       name: 'ShipmentRecord',
//       parentId: 10,
//       id: 23,
//       meta: {
//         title: '出貨記錄',
//         show: true
//       },
//       component: 'ShipmentRecord'
//     },
//     {
//       name: 'StorehouseSupervise',
//       parentId: 10,
//       id: 24,
//       meta: {
//         title: '倉存管理',
//         show: true
//       },
//       component: 'StorehouseSupervise'
//     },
//     {
//       name: 'StorehousePrompt',
//       parentId: 10,
//       id: 25,
//       meta: {
//         title: '缺貨提示',
//         show: true
//       },
//       component: 'StorehousePrompt'
//     },
//     {
//       name: 'StorehouseReturn',
//       parentId: 10,
//       id: 25,
//       meta: {
//         title: '退貨管理',
//         show: true
//       },
//       component: 'StorehouseReturn'
//     },
//     {
//       name: 'purchaseRecord',
//       parentId: 11,
//       id: 26,
//       meta: {
//         title: '分店採購記錄',
//         show: true
//       },
//       component: 'PurchaseRecord'
//     },
//     {
//       name: 'materialRecord',
//       parentId: 11,
//       id: 27,
//       meta: {
//         title: '分店物料採購量記錄',
//         show: true
//       },
//       component: 'MaterialRecord'
//     },
//     {
//       name: 'inventoryRecord',
//       parentId: 11,
//       id: 28,
//       meta: {
//         title: '分店盤點記錄',
//         show: true
//       },
//       component: 'InventoryRecord'
//     },
//     {
//       name: 'selfPurchaseRecord',
//       parentId: 11,
//       id: 29,
//       meta: {
//         title: '分店自行採購記錄',
//         show: true
//       },
//       component: 'SelfPurchaseRecord'
//     },
//     {
//       name: 'deliverySetting',
//       parentId: 12,
//       id: 30,
//       meta: {
//         title: '預設設定',
//         show: true
//       },
//       component: 'DeliverySetting'
//     },
//     {
//       name: 'roleManagement',
//       parentId: 3,
//       id: 31,
//       meta: {
//         title: '職位管理',
//         show: true
//       },
//       component: 'RoleManagement'
//     },
//     {
//       name: 'branchUser',
//       parentId: 3,
//       id: 32,
//       meta: {
//         title: '分店設定-登入設定',
//         show: true
//       },
//       component: 'BranchUser'
//     },
//     {
//       name: 'internalDispatch',
//       parentId: 12,
//       id: 33,
//       meta: {
//         title: '內部調遣',
//         show: true
//       },
//       component: 'InternalDispatch'
//     },
//     {
//       name: 'carManagement',
//       parentId: 12,
//       id: 34,
//       meta: {
//         title: '車輛管理',
//         show: true
//       },
//       component: 'CarManagement'
//     },
//     {
//       name: 'processingMaterials',
//       parentId: 14,
//       id: 35,
//       meta: {
//         title: '加工材料',
//         show: true
//       },
//       component: 'ProcessingMaterials'
//     },
//     {
//       name: 'categoryManagement',
//       parentId: 3,
//       id: 36,
//       meta: {
//         title: '貨品類別管理',
//         show: true
//       },
//       component: 'CategoryManagement'
//     },
//     {
//       name: 'goodsManagement',
//       parentId: 3,
//       id: 37,
//       meta: {
//         title: '貨品管理',
//         show: true
//       },
//       component: 'GoodsManagement'
//     },
//     {
//       name: 'supplierUserManagement',
//       parentId: 9,
//       id: 38,
//       meta: {
//         title: '供应商设定-登入设定',
//         show: true
//       },
//       component: 'SupplierUserManagement'
//     },
//     {
//       name: 'WarehouseUser',
//       parentId: 3,
//       id: 39,
//       meta: {
//         title: '倉庫管理員設定',
//         show: true
//       },
//       component: 'WarehouseUser'
//     },
//     {
//       name: 'BranchStorePurchaseOrder',
//       parentId: 12,
//       id: 40,
//       meta: {
//         title: '派貨記錄',
//         show: true
//       },
//       component: 'BranchStorePurchaseOrder'
//     },
//     {
//       name: 'kitchen',
//       parentId: 0,
//       id: 41,
//       meta: {
//         icon: 'dashboard',
//         title: '厨房管理',
//         show: true
//       },
//       component: 'RouteView'
//     },
//     {
//       name: 'KitchenIncomingRecord',
//       parentId: 41,
//       id: 42,
//       meta: {
//         title: '進貨記錄',
//         show: true
//       },
//       component: 'KitchenIncomingRecord'
//     },
//     {
//       name: 'Menu',
//       parentId: 41,
//       id: 43,
//       meta: {
//         title: '加工貨品清單',
//         show: true
//       },
//       component: 'Menu'
//     },
//     {
//       name: 'ProductionCalendar',
//       parentId: 41,
//       id: 44,
//       meta: {
//         title: '每日加工貨品',
//         show: true
//       },
//       component: 'ProductionCalendar'
//     },
//     {
//       name: 'Inventory',
//       parentId: 41,
//       id: 45,
//       meta: {
//         title: '倉存',
//         show: true
//       },
//       component: 'Inventory'
//     },
//     {
//       name: 'KitchenShipmentRecord',
//       parentId: 41,
//       id: 46,
//       meta: {
//         title: '出貨記錄',
//         show: true
//       },
//       component: 'KitchenShipmentRecord'
//     }
//   ]
//   const json = builder(nav)
//   console.log('json', json)
//   return json
// }

Mock.mock(/user\/info/, 'get', info)
// Mock.mock(/user\/nav/, 'get', userNav)
